<template>
  <el-card v-loading="loading" style="margin: 10px auto; width: 60%;">
    <task-detail-table
        :form="task"
    ></task-detail-table>
    <div style="margin-top: 10px" v-if="task.username === bossUserName">
      <el-button id="get-task-btn" type="warning" @click="gotoReportList($route.params.taskId)">
      查看所有报告
    </el-button>
    </div>
  </el-card>

</template>

<script>
import TaskDetailTable from "@/components/new/task-detail-table/TaskDetailTable";
import {getCollaborationTaskDetail} from "@/api/task";
export default {
  name: "CollaborationTaskDetail",
  components: {TaskDetailTable},
  data(){
    return {
      task: {},
      loading: false
    }
  },
  mounted() {
    this.loading = true;
    getCollaborationTaskDetail(this.$route.params.taskId)
    .then(res => {
      if(res.code === 200){
        res.data.type = '协作测试';
        this.task = res.data;

      }else{
        throw new Error(res.msg);
      }
    }).catch(e => {
      this.$message.error(e.message);
    }).finally(() => {
      this.loading = false;
    })
  },
  methods: {
    gotoReportList(taskId){
      this.$router.push(`/boss/mytasks/CollaborationTaskReportList/${taskId}`);
    }
  },
  computed: {
    bossUserName(){
      return sessionStorage.getItem('username');
    }
  }
}
</script>

<style scoped>

</style>
